/* eslint-disable comma-dangle */
import confjson from './confjson.js'

function cfglevel (key) {
  var lv = key
  var conf = confjson.ConfigDescLevel[lv]
  if (typeof (conf) === 'undefined') {
    lv = 1
    conf = confjson.ConfigDescLevel[lv]
  }
  return conf
}
function levelcolor (key) {
  var conf = cfglevel(key)
  return '#' + conf.Color + '#'
}

function colorlevel (key) {
  var conf = cfglevel(key)
  return '#' + conf.Color + '#' + conf.Desc + '#NOR#'
}

function cfgfamily (key) {
  var conf = confjson.ConfigFamily[key]
  if (typeof (conf) === 'undefined') {
    return null
  }
  return conf
}
function familycolor (key) {
  var conf = cfgfamily(key)
  if (conf === null) {
    return ''
  }
  return '#' + conf.Color + '#'
}
function colorfamily (key) {
  var color = familycolor(key)
  if (color === '') {
    return key
  }
  return color + key + '#NOR#'
}

export default {
  cfglevel,
  levelcolor,
  colorlevel,

  cfgfamily,
  familycolor,
  colorfamily,

}
